<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>预约安检记录详情</title>
</head>
<link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css">
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css">

<link rel="stylesheet" href="../../src/dist/css/page.css">

<body>
<div class="weui-cells SecurityRecord-detail">
    <div class="weui-cells__tips">预约记录详情</div>
    <div class="weui-cells" id="DemoBaseInfo">
        <img src="../../src/dist/img/nodata.png" alt="" class="nodataImg">
    </div>
</div>

<script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>

<!-- Dist -->
<script src="../../src/dist/js/index.js"></script>
<script src="../../src/dist/js/utils.js"></script>
<script src="../../src/dist/js/request.js"></script>
<script>
    var detailData = [],
		id = '';
    $(function(){
        var paras = location.search;            //search获得地址中的参数，内容为'?itemId=12'
        var result = paras.match(/[^\?&]*=[^&]*/g);     //match是字符串中符合的字段一个一个取出来，result中的值为['login=xx','table=admin']
        paras = {};                    //让paras变成没有内容的json对象
        for (i in result) {
            var temp = result[i].split('=');    //split()将一个字符串分解成一个数组,两次遍历result中的值分别为['itemId','xx']
            paras[temp[0]] = temp[1];
        }
		id = paras.id;     //根据参数名"itemId"，获取参数值

        //getSecurityRecordDetail()   //真实接口数据
		getSecurityRecordDetailPHP() // 本地测试数据
    })

    function getSecurityRecordDetailPHP() {
        $.ajax({
            type: "POST",
            url: "../../src/php/requestOnline.php",
            data: {
                act: 'CSRQ_getAppointmentDetail'
            },
            success: function (data) {
                data = eval('(' + data + ')')
				detailData = data
                createListDemo()
            },
            error: function (data) {

            }
        });
	}
    function getSecurityRecordDetail() {
        $.ajax({
            type: "POST",
            url: CJINGdataLink+"/Controllers/CustomerServiceCenter/PartyCheckHandler.ashx",
            data: {
                cmd: " view  ", JsonData: JSON.stringify({ID  :id })
            },
            success: function (data) {
                data = eval('(' + data + ')')
                if(data.list.length ===0 ){
                    $.toast('暂无数据!', 'text');
                    return
                }
                detailData = data
                createListDemo()
            },
            error: function (data) {
                $.toast('获取数据失败!', 'forbidden');
            }
        });
	}
	function createListDemo(){
			let d = detailData
			let h = ''

        //处理详情信息
        h += '<div class="list-card">\n' +
            '            <div class="detail">\n' +
            '                <i class="iconfont iconyonghuming"></i>\n' +
            '                <span class="s1">用户名称：</span>\n' +
            '                <span class="s2">'+d['PartyName']+'</span>\n' +
            '            </div>\n' +
            '            <div class="detail">\n' +
            '                <i class="iconfont iconzhanghao"></i>\n' +
            '                <span class="s1"> 用户号：</span>\n' +
            '                <span class="s2">'+d['PartyCode']+'</span>\n' +
            '            </div>\n' +
            '            <div class="detail">\n' +
            '                <i class="iconfont icondizhi"></i>\n' +
            '                <span class="s1"> 用户地址：</span>\n' +
            '               <span class="s2">'+(d['PartyAddress'])+'</span>\n' +
            '            </div>\n' +
            '            <div class="detail">\n' +
            '                <i class="iconfont icondianhua"></i>\n' +
            '                <span class="s1"> 用户电话：</span>\n' +
            '                <span class="s2">'+ d['PartyPhone']+'</span>\n' +
            '            </div>\n' +
            '            <div class="detail">\n' +
            '                <i class="iconfont iconleixing"></i>\n' +
            '                <span class="s1"> 类型：</span>\n' +
            '                <span class="s2">'+ (Number(d['Type']) == 0 ? "安检":"点火")+'</span>\n' +
            '            </div>\n' +
            '            <div class="detail">\n' +
            '                <i class="iconfont iconshijian"></i>\n' +
            '                <span class="s1"> 预约时间：</span>\n' +
            '                <span class="s2">'+ d['ApplyDate']+'</span>\n' +
            '            </div>\n' +
            '        </div>'

			$("#DemoBaseInfo").html(h)
    }

    // 点击隐患项
    function dangeInfoClick(obj) {
        let w = $(obj).attr("weizhi")
        let a = w.split("-")
        let isdanger = $(obj).hasClass("isdanger")
        if(!isdanger){
            return
        }

        let c = detailData[a[0]]['Children'][a[1]]['Children'][a[2]]['Children'][1]['HCheckTypeWorkList']

        let h = ''
        for(let [i,item] of c.entries()){
            console.log(item)
            if(Number(item.DataValue) == 1){
                h += '<span style="display: inline-block;margin: 2vw;padding: 2vw;font-size: 0.7rem;background: #FFE5B8;color:#f3a626;border-radius: 3px;">'+item.Name+'</span>'
            }
        }
        $.modal({
            title: "隐患情况",
            text: h,
            buttons: [
                { text: "关闭", className: "default", onClick: function(){ console.log(3)} },
            ]
        });
    }

</script>
</body>
</html>
